package com.yang.action;

import com.yang.entity.User;
import com.yang.service.UserService;
import com.yang.util.RespEntity;
import com.yang.util.RespUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Date;

@WebServlet("/saveUser")
public class UserSaveAction extends HttpServlet {
    UserService userService = new UserService();
    //用户注册
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //创建用户对象
        User user = new User();
        //得到传过来的name//封装成对象
        String login = req.getParameter("login");
        user.setLogin(login);
        String name = req.getParameter("name");
        user.setName(name);
        String pwd = req.getParameter("pwd");
        user.setPwd(pwd);
        String master = "1";
        user.setMaster(Integer.parseInt(master));
        RespEntity respEntity=userService.saveUser(user);
        RespUtil.sendJSON(resp,respEntity);
    }
}

